class ContactController < ApplicationController
  needs :styles => :modalbox, :scripts => :modalbox

  def new
    @contact_handler = ContactHandler.new
  end

  def create
    @contact_handler = ContactHandler.new(params[:contact_handler])

    if @contact_handler.save
     if simple_captcha_valid?
      ContactMailer.deliver_contact_notification(@contact_handler)
      flash[:notice] = 'Сообщение отправлено.'
      redirect_to :back
 	 else
 	 	 @contact_handler.errors.add("Защита от спама", "Неправильно введены слова")
 	 	 render :action => "new"
 	 end
    else
      render :action => "new"
    end
  end

end